import { startNodeAuthServerSide } from "./gateway/index";
import { start as startImageService } from "maishu-image-service"
import { start as startAdmin } from "maishu-admin";
import { config } from "./config";
import path = require("path");
import { start as startShop } from "maishu-haoyi-shop";
import { start as startPageDesigner } from "maishu-haoyi-page-designer";

startNodeAuthServerSide({
    // bindIP: config.nodeAuth.bindIP,
    port: config.nodeAuth.port,
    db: config.nodeAuth.db,
    proxy: config.nodeAuth.proxy,
    initDatabase: false,
    permissions: config.nodeAuth.permissions
});

startAdmin({
    port: config.admin.port,
    controllerPath: path.join(__dirname, "./frontend/server/controllers"),
    staticRootDirectory: path.join(__dirname, "./frontend/www"),
    gateway: `http://127.0.0.1:${config.nodeAuth.port}/auth`,
    // proxy: config.admin.proxy,
    virtualPaths: {
        "node_modules": path.join(__dirname, "../node_modules")
    }
})

startImageService({
    port: config.imageService.port,
    db: config.imageService.db,
})

startPageDesigner({
    port: config.designer.port,
    gateway: `http://127.0.0.1:${config.nodeAuth.port}/auth`,
    node_modules: path.join(__dirname, "../node_modules"),
})

startShop({
    port: config.shop.port,
    gateway: `http://127.0.0.1:${config.nodeAuth.port}/auth`,
    node_modules: path.join(__dirname, "../node_modules"),
})